from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        # 滑动窗口第一题
        left,right = 0,0
        window = {}
        res = ""
        while right < len(s):
            a = s[right]
            right +=1
            window[a] = window.get(a,0)+1
            while  window[a] > 1:
                b = s[left]
                left+=1
                window[b] = window.get(b,0)-1
            res = s[left:right] if len(res) < (right - left) else res
        return len(res)
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    solution.lengthOfLongestSubstring("pwwkew")
    # your test code here